﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UniversityManagementSystem.DAL;
using UniversityManagementSystem.Manager;

namespace UniversityManagementSystem.UI
{
    public partial class DepartmentEntry : System.Web.UI.Page
    {
        Department aDepartment;
        protected void Page_Load(object sender, EventArgs e)
        {
            aDepartment = new Department();
        }

        protected void saveDepartmentButton_Click(object sender, EventArgs e)
        {
            try
            {
                string saveDepartmentMessage = "";
                aDepartment.DepartmentCode = departmentCodeTextBox.Text;
                aDepartment.DepartmentName = departmentNameTextBox.Text;
                saveDepartmentMessage = aDepartment.SaveNewDepartment();
                messageLabel.Text = saveDepartmentMessage;
                messageLabel.ForeColor = System.Drawing.Color.Blue;
            }
            catch(Exception exception)
            {
                messageLabel.Text = "A network error occured,Please check your connection";
                messageLabel.ForeColor = System.Drawing.Color.Red;
            }

        }

        protected void showAllDepartmentButton_Click(object sender, EventArgs e)
        {
            Response.Redirect("ViewAllDepartment.aspx");
        }
    }
}